using UnityEngine;

namespace MaterialUI
{
	public static class ColorExtension
	{
		public static Color WithAlpha(this Color color, float alpha)
		{
			return new Color(color.r, color.g, color.b, alpha);
		}

		public static bool Approximately(this Color thisColor, Color otherColor, bool compareAlpha = false)
		{
			if (!Mathf.Approximately(thisColor.r, otherColor.r))
			{
				return false;
			}
			if (!Mathf.Approximately(thisColor.g, otherColor.g))
			{
				return false;
			}
			if (!Mathf.Approximately(thisColor.b, otherColor.b))
			{
				return false;
			}
			if (!compareAlpha)
			{
				return true;
			}
			return Mathf.Approximately(thisColor.a, otherColor.a);
		}
	}
}
